package edu.isistan.metamodel;

import java.util.Vector;
/**
 * Represents an interface
 */
public class Interface extends ModelElement{
	private String name;
	private String doc;
	private Vector<Operation> operations;

	public Interface(String name, String doc, Vector<Operation> operations) {		
		this.name = name;
		this.doc = doc;
		this.operations = operations;
	}

	public Interface() {
		this.name = null;
		this.doc = null;
		this.operations = null;
	}

	public Interface(Interface aInterface) {
		super(aInterface);
		this.name = aInterface.getName();
		this.doc = aInterface.getDoc();
		this.operations = new Vector<Operation>();
		for (Operation operation : aInterface.getOperations()) {
			this.operations.add(new Operation(operation));	
		}
	}
	public String getDoc() {
		return doc;
	}

	public void setDoc(String doc) {
		this.doc = doc;
	}

	public Vector<Operation> getOperations() {
		return operations;
	}

	public void setOperations(Vector<Operation> operations) {
		this.operations = operations;
	}

	public int getOperationsSize() {
		if(operations != null)
			return operations.size();
		else 
			return 0;
	}

	public Operation getOperation(int num) {
		return operations.get(num);
	}
	
	public void addOperation(Operation operation) {
		if(operations == null)
			operations = new Vector<Operation>();
		operations.add(operation);
	}	

	public String getName(){
		return this.name;
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("{name=");
		sb.append(getName());
		sb.append(";operations=[");
		for (Operation operation : operations)
			sb.append(operation.toString());
		sb.append("]}");
		return sb.toString();
	}
}
